package com.gupao.gupaoeduvippattern.javaBase.thread.ticket;

/**
 * @author Administrator
 * @date 2020-12-03 19:19
 */
public class Window extends Thread {

    public static int ticket = 100;

    public static int count = 1;

    /**
     * If this thread was constructed using a separate
     * {@code Runnable} run object, then that
     * {@code Runnable} object's {@code run} method is called;
     * otherwise, this method does nothing and returns.
     * <p>
     * Subclasses of {@code Thread} should override this method.
     *
     * @see #start()
     * @see #stop()
     */
    @Override
    public synchronized void run() {
        while(true){
            if(ticket > 0){
                ticket--;
                System.out.println(this.getName() + "已经卖出一张，还剩" + ticket +"张");
            }else{
                System.out.println("票已经卖完！");
                break;
            }


        }

    }
}
